<template class="app">
  <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
    <el-tab-pane label="上传配置" name="first">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="上传配置">
          <el-radio-group v-model="form.upload_status">
            <el-radio :label="1">本地存储</el-radio>
            <el-radio :label="2">七牛云</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
        </el-form-item>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="系统参数" name="second"></el-tab-pane>
  </el-tabs>
</template>

<script>
import { SetConf, GetConf } from '@/api/config'
export default {
  data() {
    return {
      activeName: 'first',
      form: {
        upload_status: undefined
      },
      upload_config: []
    }
  },
  created() {
    this.getConfig()
  },
  methods: {
    handleClick(tab, event) {
      // console.log(tab, event)
    },
    async getConfig() {
      const res = await GetConf()
      switch (res.code) {
        case -1:
          this.$notify({
            title: '提示',
            message: res.msg,
            duration: 0
          })
          break
        case 200:
          this.upload_config = res.data.upload_status
          this.form.upload_status = parseInt(res.data.upload_status.upload_status)
          break
      }
    },
    async onSubmit() {
      const res = await SetConf(this.form)
      switch (res.code) {
        case -1:
          this.$notify({
            title: '提示',
            message: res.msg,
            duration: 0
          })
          break
        case 200:
          this.$notify({
            title: '成功',
            message: res.msg,
            type: 'success'
          })
          break
      }
    }
  }
}
</script>

<style scoped>

</style>
